home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / c / agl103p.lha / src / agl / RCS / que.c,v < prev    next >
Text File  |  1994-12-08  |  31KB  |  1,657 lines

  1. head    1.2;
  2. branch    1.2.1.99;
  3. access;
  4. symbols;
  5. locks; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.2
  10. date    93.01.27.17.42.22;    author jason;    state Exp;
  11. branches
  12.     1.2.1.1;
  13. next    ;
  14.  
  15. 1.2.1.1
  16. date    94.03.29.05.41.32;    author jason;    state Exp;
  17. branches;
  18. next    1.2.1.2;
  19.  
  20. 1.2.1.2
  21. date    94.04.06.02.42.15;    author jason;    state Exp;
  22. branches;
  23. next    1.2.1.3;
  24.  
  25. 1.2.1.3
  26. date    94.09.13.03.52.07;    author jason;    state Exp;
  27. branches;
  28. next    1.2.1.4;
  29.  
  30. 1.2.1.4
  31. date    94.11.16.06.28.44;    author jason;    state Exp;
  32. branches;
  33. next    1.2.1.5;
  34.  
  35. 1.2.1.5
  36. date    94.12.09.05.29.56;    author jason;    state Exp;
  37. branches;
  38. next    ;
  39.  
  40.  
  41. desc
  42. @device event que handling
  43. @
  44.  
  45.  
  46. 1.2
  47. log
  48. @Initial RCS Version
  49. @
  50. text
  51. @#include"agl.h"
  52. #include"keymap.h"
  53.  
  54. #define QDEBUG        FALSE
  55. #define MAXKEYINPUT    128
  56.  
  57. struct InputEvent InEvent={0,IECLASS_RAWKEY,0,0,0};
  58.  
  59. short Tie[MAX_DEVICE][2];
  60. short Queued[MAX_DEVICE];
  61. short ButtonState[MAX_DEVICE];
  62. short QRead,QWrite;
  63. short Mousex,Mousey,LastMousex=0,LastMousey=0;
  64. short Mouse2x=0,Mouse2y=0;
  65.  
  66. long Queue[QUEUE_SIZE][2];
  67. long GLFocus=0;
  68.  
  69.  
  70.  
  71. /******************************************************************************
  72. void    qinit(void)
  73.  
  74. ******************************************************************************/
  75. /*PROTOTYPE*/
  76. void qinit(void)
  77.     {
  78.     short m;
  79.  
  80.     QRead=0;
  81.     QWrite=0;
  82.  
  83.     for(m=0;m<MAX_DEVICE;m++)
  84.         {
  85.         Queued[m]=FALSE;
  86.         Tie[m][0]=0;
  87.         Tie[m][1]=0;
  88.         }
  89.  
  90.     clear_buttons(TRUE);
  91.  
  92.     Queued[REDRAW]=TRUE;
  93.     Queued[INPUTCHANGE]=TRUE;
  94.     }
  95.  
  96.  
  97. /******************************************************************************
  98. void    tie(long dev,long valuator1,long valuator2)
  99.  
  100. ******************************************************************************/
  101. /*PROTOTYPE*/
  102. void tie(long dev,long valuator1,long valuator2)
  103.     {
  104.     Tie[dev][0]=valuator1;
  105.     Tie[dev][1]=valuator2;
  106.     }
  107.  
  108.  
  109. /******************************************************************************
  110. void    qdevice(long dev)
  111.  
  112. ******************************************************************************/
  113. /*PROTOTYPE*/
  114. void qdevice(long dev)
  115.     {
  116.     Queued[dev]=TRUE;
  117.     }
  118.  
  119.  
  120. /******************************************************************************
  121. void    unqdevice(long dev)
  122.  
  123. ******************************************************************************/
  124. /*PROTOTYPE*/
  125. void unqdevice(long dev)
  126.     {
  127.     Queued[dev]=FALSE;
  128.     }
  129.  
  130.  
  131. /******************************************************************************
  132. long    isqueued(long dev)
  133.  
  134. ******************************************************************************/
  135. /*PROTOTYPE*/
  136. long isqueued(long dev)
  137.     {
  138.     return Queued[dev];
  139.     }
  140.  
  141.  
  142. /******************************************************************************
  143. void    qenter(long dev,short val)
  144.  
  145. ******************************************************************************/
  146. /*PROTOTYPE*/
  147. void qenter(long dev,short val)
  148.     {
  149.     Queue[QWrite][0]=dev;
  150.     Queue[QWrite][1]=val;
  151.     QWrite++;
  152.     if(QWrite==QRead)
  153.         {
  154.         GL_error("Queue filled: event overrun");
  155.         QRead++;
  156.         if(QRead==QUEUE_SIZE)
  157.             QRead=0;
  158.         }
  159.     if(QWrite==QUEUE_SIZE)
  160.         QWrite=0;
  161.     }
  162.  
  163.  
  164. /******************************************************************************
  165. long    qtest(void)
  166.  
  167. ******************************************************************************/
  168. /*PROTOTYPE*/
  169. long qtest(void)
  170.     {
  171.     update_queue();
  172.  
  173.     if(QRead==QWrite)
  174.         return 0;
  175.     else
  176.         return Queue[QRead][0];
  177.     }
  178.  
  179.  
  180. /******************************************************************************
  181. long    qread(short *data)
  182.  
  183. ******************************************************************************/
  184. /*PROTOTYPE*/
  185. long qread(short *data)
  186.     {
  187.     long device;
  188.  
  189.     while(QRead==QWrite)
  190.         {
  191.         update_queue();
  192.         micropause();
  193.         }
  194.  
  195.     device=Queue[QRead][0];
  196.     *data=Queue[QRead][1];
  197.     QRead++;
  198.     if(QRead==QUEUE_SIZE)
  199.         QRead=0;
  200.  
  201.     return device;
  202.     }
  203.  
  204.  
  205. /******************************************************************************
  206. void    qreset(void)
  207.  
  208. ******************************************************************************/
  209. /*PROTOTYPE*/
  210. void qreset(void)
  211.     {
  212.     QRead=QWrite;
  213.     }
  214.  
  215.  
  216. /******************************************************************************
  217. long    getvaluator(long val)
  218.  
  219. ******************************************************************************/
  220. /*PROTOTYPE*/
  221. long getvaluator(long val)
  222.     {
  223.     long result=0;
  224.  
  225.     switch(val)
  226.         {
  227.         case MOUSEX:
  228.             result=GLScreen->MouseX;
  229.             break;
  230.         case MOUSEY:
  231.             result=SCREENY-1-GLScreen->MouseY;
  232.             break;
  233.         }
  234.     return result;
  235.     }
  236.  
  237.  
  238. /******************************************************************************
  239. long    getbutton(long num)
  240.  
  241. ******************************************************************************/
  242. /*PROTOTYPE*/
  243. long getbutton(long num)
  244.     {
  245.     update_queue();
  246.  
  247.     return (long)ButtonState[num];
  248.     }
  249.  
  250.  
  251. /******************************************************************************
  252. void clear_buttons(long init)
  253.  
  254.     resets state of mouse buttons
  255.  
  256.     unless init, issues que entry for switch off
  257.  
  258. ******************************************************************************/
  259. /*PROTOTYPE*/
  260. void clear_buttons(long init)
  261.     {
  262.     long m;
  263.  
  264.     for(m=0;m<MAX_DEVICE;m++)
  265.         {
  266.         if(ButtonState[m] && Queued[m] && !init)
  267.             qenter_tie(m,(short)FALSE);
  268.  
  269.         ButtonState[m]=FALSE;
  270.         }
  271.     }
  272.  
  273.  
  274. /*******************************************************************************
  275. void    update_queue(void)
  276.  
  277.     a manual MOUSEX,MOUSEY move check is much better than having Intuition
  278.         flood the system with reports
  279.  
  280. *******************************************************************************/
  281. /*PROTOTYPE*/     
  282. void update_queue(void)
  283.     {
  284.     struct IntuiMessage *message,*mess1,*mess2;
  285.     struct MsgPort *userport;
  286.     ULONG class;
  287.     USHORT code;
  288.     UWORD qualifier;
  289.     char string[MAXKEYINPUT];
  290.     long wid,device;
  291.     short inside,data;
  292.     short ascii,c,length,mx,my;
  293.  
  294.     Mousex=getvaluator(MOUSEX);
  295.     Mousey=getvaluator(MOUSEY);
  296.  
  297. #if MICE
  298.     while(gameport_event(&device,&data,&mx,&my))    /* mx,my = delta mouse position */
  299.         {
  300. /*
  301.         if(device && Queued[device])
  302.             qenter_tie(device,data);
  303. */
  304.             
  305.         if(mx || my)
  306.             {
  307.             Mouse2x+=mx;
  308.             Mouse2y+=my;
  309.  
  310.             if(Mouse2x<0)
  311.                 Mouse2x=0;
  312.             if(Mouse2x>SCREENX-1)
  313.                 Mouse2x=SCREENX-1;
  314.  
  315.             if(Mouse2y<0)
  316.                 Mouse2y=0;
  317.             if(Mouse2y>SCREENY-1)
  318.                 Mouse2y=SCREENY-1;
  319.  
  320. /*
  321.             if(Queued[BPADX])
  322.                 qenter(BPADX,Mouse2x);
  323.  
  324.             if(Queued[BPADY])
  325.                 qenter(BPADY,Mouse2y);
  326. */
  327.  
  328.             move_mousesprite((long)Mouse2x,(long)Mouse2y);
  329.             }
  330.         }
  331. #endif
  332.  
  333.     if( (Queued[MOUSEX]||Queued[MOUSEY]) && (Mousex!=LastMousex||Mousey!=LastMousey)
  334.                                                                 && is_inside(GLFocus,Mousex,Mousey) )
  335.         {
  336.         if(Queued[MOUSEX])
  337.             qenter(MOUSEX,Mousex);
  338.         if(Queued[MOUSEY])
  339.             qenter(MOUSEY,Mousey);
  340.         }
  341.  
  342.     LastMousex=Mousex;
  343.     LastMousey=Mousey;
  344.  
  345.     for(wid=1;wid<MAX_WINDOWS;wid++)
  346.         {
  347.         if(GLWindow[wid])
  348.             {
  349.             userport=GLWindow[wid]->UserPort;
  350.             inside=is_inside(wid,Mousex,Mousey);
  351.  
  352.             while(message=(struct IntuiMessage *)GetMsg(userport))
  353.                 {                                                                       
  354.                 device=0;
  355.                 data=0;
  356.  
  357.                 class=message->Class;
  358.                 code=message->Code;
  359.                 qualifier=message->Qualifier;
  360.                 mx=message->MouseX;
  361.                 my=message->MouseY;
  362.  
  363.                 ButtonState[LEFTMOUSE]= (qualifier&IEQUALIFIER_LEFTBUTTON)!=0;
  364.                 ButtonState[MIDDLEMOUSE]= (qualifier&IEQUALIFIER_MIDBUTTON)!=0;
  365.                 ButtonState[RIGHTMOUSE]= (qualifier&IEQUALIFIER_RBUTTON)!=0;
  366.             
  367.                 ReplyMsg((struct Message *)message);
  368.  
  369.                 switch(class)
  370.                     {
  371.                     case CLOSEWINDOW:
  372.                         if(QDEBUG)
  373.                             printf("Msg: CLOSEWINDOW on %d: %d,%d code=%d\n",wid,mx,my,code);
  374.                         device=WINQUIT;
  375.                         data=TRUE;
  376.                         break;
  377.                     case REFRESHWINDOW:
  378.                         if(QDEBUG)
  379.                             printf("Msg: REFRESHWINDOW on %d: %d,%d code=%d\n",wid,mx,my,code);
  380.  
  381.                         /* optimally refresh occurs between these, but not convenient in GL */
  382.                         BeginRefresh(GLWindow[wid]);
  383.                         EndRefresh(GLWindow[wid],TRUE);
  384.  
  385.                         device=REDRAW;
  386.                         data=wid;
  387.                         break;
  388.                     case ACTIVEWINDOW:
  389.                         if(QDEBUG)
  390.                             printf("Msg: ACTIVEWINDOW on %d: %d,%d code=%d\n",wid,mx,my,code);
  391.                         if(GLFocus!=0)
  392.                             qenter_tie(INPUTCHANGE,(short)0);
  393.                         GLFocus=wid;
  394.                         device=INPUTCHANGE;
  395.                         data=wid;
  396.                         break;
  397.                     case INACTIVEWINDOW:
  398.                         if(QDEBUG)
  399.                             printf("Msg: INACTIVEWINDOW on %d: %d,%d code=%d\n",wid,mx,my,code);
  400.                         if(GLFocus==wid)
  401.                             {
  402.                             GLFocus=0;
  403.                             device=INPUTCHANGE;
  404.                             data=0;
  405.                             clear_buttons(FALSE);
  406.                             }
  407.                         break;
  408.                     case MOUSEMOVE:
  409.                         if(QDEBUG)
  410.                             printf("Msg: MOUSEMOVE on %d: %d,%d code=%d\n",wid,mx,my,code);
  411.                         if(inside)
  412.                             {
  413.                             if(Queued[MOUSEX])
  414.                                 qenter(MOUSEX,Mousex);
  415.                             if(Queued[MOUSEY])
  416.                                 qenter(MOUSEY,Mousey);
  417.                             }
  418.                         break;
  419.                     case MOUSEBUTTONS:
  420.                         if(QDEBUG)
  421.                             printf("Msg: MOUSEBUTTONS on %d: %d,%d code=%d\n",wid,mx,my,code);
  422.                         switch(code)
  423.                             {
  424.                             case SELECTDOWN:
  425.                                 device=LEFTMOUSE;
  426.                                 data=TRUE;
  427.                                 break;
  428.                             case SELECTUP:
  429.                                 device=LEFTMOUSE;
  430.                                 data=FALSE;
  431.                                 break;
  432.                             case MIDDLEDOWN:
  433.                                 device=MIDDLEMOUSE;
  434.                                 data=TRUE;
  435.                                 break;
  436.                             case MIDDLEUP:
  437.                                 device=MIDDLEMOUSE;
  438.                                 data=FALSE;
  439.                                 break;
  440.                             case MENUDOWN:
  441.                                 device=RIGHTMOUSE;
  442.                                 data=TRUE;
  443.                                 break;
  444.                             case MENUUP:
  445.                                 device=RIGHTMOUSE;
  446.                                 data=FALSE;
  447.                                 break;
  448.                             }
  449.  
  450. /*
  451.                         if(!inside)
  452.                             device=NULL;
  453. */
  454.                         break;
  455.                     case RAWKEY:
  456.                         if(QDEBUG)
  457.                             printf("Msg: RAWKEY on %d: %d,%d code=%d\n",wid,mx,my,code);
  458.                         if(inside)
  459.                             {
  460.                             if(!(code&IECODE_UP_PREFIX))
  461.                                 {
  462.                                 InEvent.ie_Code=code;
  463.                                 InEvent.ie_Qualifier=qualifier;
  464.                                 length=RawKeyConvert(&InEvent,string,MAXKEYINPUT,NULL);
  465.  
  466.                                 if(length>0)
  467.                                     {
  468.                                     string[length]=0;
  469.  
  470.                                     if(QDEBUG)
  471.                                         for(c=0;string[c];c++)
  472.                                             printf("     %2x %3d '%c'\n",string[c],string[c],string[c]);
  473.  
  474.                                     if(Queued[KEYBD] && length==1)
  475.                                         {
  476.                                         ascii=string[0];
  477.                                         device=KEYBD;
  478.                                         data=ascii;
  479.                                         }
  480.                                     }
  481.                                 }
  482.                             }
  483.                         quekeys(code,inside);
  484.  
  485.                         /* prevent running */
  486.                         mess1=(struct IntuiMessage *) userport->mp_MsgList.lh_Head;
  487.                         while(mess2=(struct IntuiMessage *)mess1->ExecMessage.mn_Node.ln_Succ)
  488.                             {
  489.                             if(mess2->ExecMessage.mn_Node.ln_Succ==NULL)
  490.                                 break;
  491.                             if(mess1->Class!=RAWKEY)
  492.                                 break;
  493.                             if(!(mess1->Qualifier & IEQUALIFIER_REPEAT))
  494.                                 break;
  495.                             if(mess2->Class != RAWKEY)
  496.                                 break;
  497.                             if(!(mess2->Qualifier & IEQUALIFIER_REPEAT))
  498.                                 break;
  499.  
  500.                             /* Message removed */
  501.                             mess1=(struct IntuiMessage *)GetMsg(userport);
  502.                             ReplyMsg((struct Message *)mess1);
  503.  
  504.                             mess1=(struct IntuiMessage *) userport->mp_MsgList.lh_Head;
  505.                             }
  506.                         break;
  507.                     }
  508.                 if(device && Queued[device])
  509.                     qenter_tie(device,data);
  510.                 }
  511.             }
  512.         }
  513.     }
  514.  
  515.  
  516. /******************************************************************************
  517. void    qenter_tie(long device,short data)
  518. ******************************************************************************/
  519. /*PROTOTYPE*/
  520. void qenter_tie(long device,short data)
  521.     {
  522.     short n;
  523.  
  524.     qenter(device,data);
  525.  
  526.     for(n=0;n<2;n++)
  527.         {
  528.         if(Tie[device][n]==MOUSEX)
  529.             qenter(MOUSEX,Mousex);
  530.         if(Tie[device][n]==MOUSEY)
  531.             qenter(MOUSEY,Mousey);
  532.         }
  533.     }
  534.  
  535.  
  536. /******************************************************************************
  537. void    quekeys(USHORT code,short inside)
  538.  
  539. ******************************************************************************/
  540. /*PROTOTYPE*/
  541. void quekeys(USHORT code,short inside)
  542.     {
  543.     long device;
  544.     short data=TRUE;
  545.  
  546.     if( code & IECODE_UP_PREFIX )
  547.         {
  548.         data=FALSE;
  549.         code-=IECODE_UP_PREFIX;
  550.         }
  551.  
  552.     if(code<KEYMAPLENGTH)
  553.         {
  554.          device=KeyRemap[code];
  555.  
  556.         if(data != ButtonState[device])
  557.             {
  558.             if(QDEBUG)
  559.                 printf("Code %2X %3d -> device=%d\n",code,data,device);
  560.  
  561.             ButtonState[device]=data;
  562.  
  563.             if(Queued[device] && inside)
  564.                 qenter_tie(device,data);
  565.             }
  566.         }
  567.     }
  568.  
  569.  
  570. /******************************************************************************
  571. short     is_inside(long wid,short x,short y)
  572.  
  573. ******************************************************************************/
  574. /*PROTOTYPE*/
  575. short is_inside(long wid,short x,short y)
  576.     {
  577.     long posx,posy,lenx,leny;
  578.     short inside;
  579.  
  580.     get_dimensions(wid,&posx,&posy,&lenx,&leny);
  581.     inside=    x>posx && x<(posx+lenx) && y>posy && y<(posy+leny) ;
  582.  
  583.     return inside;
  584.     }
  585. @
  586.  
  587.  
  588. 1.2.1.1
  589. log
  590. @Added RCS Header
  591. @
  592. text
  593. @a0 16
  594.  
  595. /******************************************************************************
  596.  
  597. $Id: que.c,v 1.2.1.1 2002/03/26 22:04:21 jason Exp jason $
  598.  
  599. $Log: que.c,v $
  600.  * Revision 1.2.1.1  2002/03/26  22:04:21  jason
  601.  * Added RCS Header
  602.  *
  603.  * Revision 1.2.1.1  2002/03/26  22:00:51  jason
  604.  * RCS/agl.h,v
  605.  *
  606.  
  607. ******************************************************************************/
  608.  
  609.  
  610. d181 1
  611. a181 1
  612.             result=GLScreen->Height-1-GLScreen->MouseY;
  613. d262 2
  614. a263 2
  615.             if(Mouse2x>GLScreen->Width-1)
  616.                 Mouse2x=GLScreen->Width-1;
  617. d267 2
  618. a268 2
  619.             if(Mouse2y>GLScreen->Height-1)
  620.                 Mouse2y=GLScreen->Height-1;
  621. @
  622.  
  623.  
  624. 1.2.1.2
  625. log
  626. @Now only updates que when it's empty
  627. @
  628. text
  629. @d4 1
  630. a4 1
  631. $Id: que.c,v 1.2.1.1 1994/03/29 05:41:32 jason Exp jason $
  632. a6 3
  633.  * Revision 1.2.1.1  1994/03/29  05:41:32  jason
  634.  * Added RCS Header
  635.  *
  636. a132 3
  637.     checks if there is event in the queue
  638.     doesn't wait, returns immediately
  639.  
  640. d137 1
  641. a137 2
  642.     if(QRead==QWrite)
  643.         update_queue();
  644. a148 3
  645.     reads queue
  646.     will wait for an event
  647.  
  648. a162 1
  649.  
  650. a163 1
  651.  
  652. a450 1
  653. #if FALSE
  654. a471 1
  655. #endif
  656. @
  657.  
  658.  
  659. 1.2.1.3
  660. log
  661. @replaced micropause() with delay()
  662. @
  663. text
  664. @d4 1
  665. a4 1
  666. $Id: que.c,v 1.2.1.2 1994/04/06 02:42:15 jason Exp jason $
  667. d7 2
  668. a8 2
  669.  * Revision 1.2.1.2  1994/04/06  02:42:15  jason
  670.  * Now only updates que when it's empty
  671. d10 1
  672. a10 1
  673.  * Revision 1.2.1.1  1994/03/29  05:41:32  jason
  674. d12 4
  675. a19 1
  676. #ifndef NOT_EXTERN
  677. a20 2
  678. #endif
  679.  
  680. a120 1
  681.  
  682. a127 1
  683.  
  684. a152 11
  685. /*******************************************************************************
  686. void    delay(void)
  687.  
  688. *******************************************************************************/
  689. /*PROTOTYPE*/
  690. void delay(void)
  691.     {
  692.     Delay(5);
  693.     }
  694.  
  695.  
  696. d168 1
  697. a168 1
  698.         delay();
  699. a354 1
  700.  
  701. a365 1
  702.  
  703. a374 1
  704.  
  705. a385 1
  706.  
  707. a396 1
  708.  
  709. a432 1
  710.  
  711. a487 1
  712.  
  713. @
  714.  
  715.  
  716. 1.2.1.4
  717. log
  718. @border support
  719. @
  720. text
  721. @d4 1
  722. a4 1
  723. $Id: que.c,v 1.2.1.3 1994/09/13 03:52:07 jason Exp jason $
  724. a6 3
  725.  * Revision 1.2.1.3  1994/09/13  03:52:07  jason
  726.  * replaced micropause() with delay()
  727.  *
  728. d22 2
  729. a23 11
  730.  
  731. #define QDEBUG            FALSE
  732.  
  733. #define MAXKEYINPUT        128
  734.  
  735. #define BORDER_LEFT        1
  736. #define BORDER_RIGHT    2
  737. #define BORDER_TOP        4
  738. #define BORDER_BOTTOM    8
  739. #define BORDER_MENU        16
  740.  
  741. a26 1
  742. short LastOrigin[MAX_WINDOWS][2];
  743. d35 1
  744. a47 2
  745.     GLFocus=0;
  746.  
  747. a50 6
  748.     for(m=0;m<MAX_WINDOWS;m++)
  749.         {
  750.         LastOrigin[m][0]= -1;
  751.         LastOrigin[m][1]= -1;
  752.         }
  753.  
  754. d145 1
  755. a145 1
  756.         update_queue(-1);
  757. d179 1
  758. a179 1
  759.         update_queue(-1);
  760. a223 1
  761.  
  762. d235 1
  763. a235 1
  764.     update_queue(-1);
  765. a253 2
  766. /*     printf("clear buttons\n"); */
  767.  
  768. d265 1
  769. a265 1
  770. void    update_queue(short waitid)
  771. a269 2
  772.     if waitid>=0, wait for event in wid specified by waitid
  773.  
  774. d272 1
  775. a272 1
  776. void update_queue(short waitid)
  777. a275 1
  778.  
  779. a278 1
  780.  
  781. d280 3
  782. a282 15
  783.  
  784.     long wid,old_wid;
  785.     long border_touch=NULL;    /* wid of window whose border is being touched */
  786.     long device;
  787.     long originx,originy;
  788.     long sizex,sizey;
  789.  
  790.     short inside;
  791.     short border;
  792.     short data;
  793.     short ascii;
  794.     short c;
  795.     short length;
  796.     short mx,my;
  797.     short waited=FALSE;
  798. d324 1
  799. a324 1
  800.                                                         && is_inside(GLFocus,Mousex,Mousey,FALSE) )
  801. d335 3
  802. a337 2
  803.     do    {
  804.         for(wid=1;wid<MAX_WINDOWS;wid++)
  805. d339 2
  806. a340 5
  807.             if(GLWindow[wid])
  808.                 {
  809.                 /* check if window has moved (no Intuition event for this) */
  810.                 get_dimensions(wid,TRUE,&originx,&originy,&sizex,&sizey);
  811.                 originy=ScreenDef.Height-originy-sizey;
  812. d342 16
  813. a357 23
  814.                 if(originx!=LastOrigin[wid][0] || originy!=LastOrigin[wid][1])
  815.                     {
  816.                     if(QDEBUG)
  817.                         printf("MOVEWINDOW (pseudo-event)\n");
  818.  
  819.                     LastOrigin[wid][0]=originx;
  820.                     LastOrigin[wid][1]=originy;
  821.  
  822.                     if(wid==waitid)
  823.                         waited=TRUE;
  824.                     }
  825.  
  826.                 userport=GLWindow[wid]->UserPort;
  827.                 inside=is_inside(wid,Mousex,Mousey,TRUE);
  828.                 if(inside)
  829.                     {
  830.                     border=!is_inside(wid,Mousex,Mousey,FALSE);
  831.  
  832.                     /* not considered inside if on border */
  833.                     inside=!border;
  834.                     }
  835.                 else
  836.                     border=FALSE;
  837. d359 1
  838. a359 1
  839.                 while(message=(struct IntuiMessage *)GetMsg(userport))
  840. d361 35
  841. a395 72
  842.                     device=0;
  843.                     data=0;
  844.  
  845.                     class=message->Class;
  846.                     code=message->Code;
  847.                     qualifier=message->Qualifier;
  848.                     mx=message->MouseX;
  849.                     my=message->MouseY;
  850.  
  851. /*    Note: ignoring button info from refresh and newsize to prevent
  852.  *    false-positive leftmouse after a resize
  853.  */
  854.  
  855.                     if( class!=NEWSIZE && class!=REFRESHWINDOW &&
  856.                                                             class!=ACTIVEWINDOW && class!=INACTIVEWINDOW )
  857.                         {
  858.                         ButtonState[LEFTMOUSE]= (qualifier&IEQUALIFIER_LEFTBUTTON)!=0;
  859.                         ButtonState[MIDDLEMOUSE]= (qualifier&IEQUALIFIER_MIDBUTTON)!=0;
  860.                         ButtonState[RIGHTMOUSE]= (qualifier&IEQUALIFIER_RBUTTON)!=0;
  861.                         }
  862.                 
  863.                     if(QDEBUG)
  864.                         printf("Msg on %d: %d,%d mb=%d%d%d code=%d ",wid,mx,my,ButtonState[LEFTMOUSE],
  865.                                                     ButtonState[MIDDLEMOUSE],ButtonState[RIGHTMOUSE],code);
  866.  
  867.                     ReplyMsg((struct Message *)message);
  868.  
  869.                     switch(class)
  870.                         {
  871.                         case CLOSEWINDOW:
  872.                             if(QDEBUG)
  873.                                 printf("CLOSEWINDOW\n");
  874.                             device=WINQUIT;
  875.                             data=TRUE;
  876.                             break;
  877.  
  878.                         case NEWSIZE:
  879.                             if(QDEBUG)
  880.                                 printf("NEWSIZE\n");
  881.  
  882. #if FALSE
  883.                             /* window resize indicates an otherwise unseen left mouse release */
  884.                             ButtonState[LEFTMOUSE]=FALSE;
  885.  
  886. #endif
  887.                             if(wid==waitid)
  888.                                 waited=TRUE;
  889.                             break;
  890.  
  891.                         case REFRESHWINDOW:
  892.                             if(QDEBUG)
  893.                                 printf("REFRESHWINDOW\n");
  894.  
  895.                             /* optimally refresh occurs between these, but not convenient in GL */
  896.                             BeginRefresh(GLWindow[wid]);
  897.                             EndRefresh(GLWindow[wid],TRUE);
  898.  
  899.                             device=REDRAW;
  900.                             data=wid;
  901.  
  902.                             drawborder(wid);
  903.                             break;
  904.  
  905.                         case ACTIVEWINDOW:
  906.                             if(QDEBUG)
  907.                                 printf("ACTIVEWINDOW\n");
  908.  
  909.                             if(GLFocus!=0)
  910.                                 qenter_tie(INPUTCHANGE,(short)0);
  911.  
  912.                             old_wid=GLFocus;
  913.                             GLFocus=wid;
  914. d397 47
  915. a443 82
  916.                             data=wid;
  917.  
  918.                             drawborder(old_wid);
  919.                             drawborder(wid);
  920.  
  921.                             RedoBorder[wid]=TRUE;
  922.                             RedoBorder[old_wid]=TRUE;
  923.                             break;
  924.  
  925.                         case INACTIVEWINDOW:
  926.                             if(QDEBUG)
  927.                                 printf("INACTIVEWINDOW\n");
  928.  
  929.                             if(GLFocus==wid)
  930.                                 {
  931.                                 old_wid=GLFocus;
  932.                                 GLFocus=0;
  933.                                 device=INPUTCHANGE;
  934.                                 data=0;
  935.                                 clear_buttons(FALSE);
  936.  
  937.                                 drawborder(old_wid);
  938.                                 RedoBorder[old_wid]=TRUE;
  939.                                 }
  940.  
  941.                             break;
  942.  
  943.                         case MOUSEMOVE:
  944.                             if(QDEBUG)
  945.                                 printf("MOUSEMOVE\n");
  946.  
  947.                             if(inside)
  948.                                 {
  949.                                 if(Queued[MOUSEX])
  950.                                     qenter(MOUSEX,Mousex);
  951.                                 if(Queued[MOUSEY])
  952.                                     qenter(MOUSEY,Mousey);
  953.                                 }
  954.                             break;
  955.  
  956.                         case MOUSEBUTTONS:
  957.                             if(QDEBUG)
  958.                                 printf("MOUSEBUTTONS\n");
  959.  
  960.                             switch(code)
  961.                                 {
  962.                                 case SELECTDOWN:
  963.                                     device=LEFTMOUSE;
  964.                                     data=TRUE;
  965.  
  966.                                     if(border)
  967.                                         border_touch=wid;
  968.                                     break;
  969.  
  970.                                 case SELECTUP:
  971.                                     device=LEFTMOUSE;
  972.                                     data=FALSE;
  973.                                     break;
  974.  
  975.                                 case MIDDLEDOWN:
  976.                                     device=MIDDLEMOUSE;
  977.                                     data=TRUE;
  978.  
  979.                                     if(border)
  980.                                         border_touch= -wid;
  981.                                     break;
  982.  
  983.                                 case MIDDLEUP:
  984.                                     device=MIDDLEMOUSE;
  985.                                     data=FALSE;
  986.                                     break;
  987.  
  988.                                 case MENUDOWN:
  989.                                     device=RIGHTMOUSE;
  990.                                     data=TRUE;
  991.                                     break;
  992.  
  993.                                 case MENUUP:
  994.                                     device=RIGHTMOUSE;
  995.                                     data=FALSE;
  996.                                     break;
  997.                                 }
  998. d446 2
  999. a447 2
  1000.                             if(!inside)
  1001.                                 device=NULL;
  1002. d449 1
  1003. a449 1
  1004.                             break;
  1005. d451 10
  1006. a460 3
  1007.                         case RAWKEY:
  1008.                             if(QDEBUG)
  1009.                                 printf("RAWKEY\n");
  1010. d462 1
  1011. a462 3
  1012.                             if(inside)
  1013.                                 {
  1014.                                 if(!(code&IECODE_UP_PREFIX))
  1015. d464 5
  1016. a468 3
  1017.                                     InEvent.ie_Code=code;
  1018.                                     InEvent.ie_Qualifier=qualifier;
  1019.                                     length=RawKeyConvert(&InEvent,string,MAXKEYINPUT,NULL);
  1020. d470 1
  1021. a470 1
  1022.                                     if(length>0)
  1023. d472 3
  1024. a474 12
  1025.                                         string[length]=0;
  1026.  
  1027.                                         if(QDEBUG)
  1028.                                             for(c=0;string[c];c++)
  1029.                                                 printf("     %2x %3d '%c'\n",string[c],string[c],string[c]);
  1030.  
  1031.                                         if(Queued[KEYBD] && length==1)
  1032.                                             {
  1033.                                             ascii=string[0];
  1034.                                             device=KEYBD;
  1035.                                             data=ascii;
  1036.                                             }
  1037. d478 2
  1038. a479 1
  1039.                             quekeys(code,inside);
  1040. d482 19
  1041. a500 1
  1042.                             /* prevent running */
  1043. d502 1
  1044. a502 19
  1045.                             while(mess2=(struct IntuiMessage *)mess1->ExecMessage.mn_Node.ln_Succ)
  1046.                                 {
  1047.                                 if(mess2->ExecMessage.mn_Node.ln_Succ==NULL)
  1048.                                     break;
  1049.                                 if(mess1->Class!=RAWKEY)
  1050.                                     break;
  1051.                                 if(!(mess1->Qualifier & IEQUALIFIER_REPEAT))
  1052.                                     break;
  1053.                                 if(mess2->Class != RAWKEY)
  1054.                                     break;
  1055.                                 if(!(mess2->Qualifier & IEQUALIFIER_REPEAT))
  1056.                                     break;
  1057.  
  1058.                                 /* Message removed */
  1059.                                 mess1=(struct IntuiMessage *)GetMsg(userport);
  1060.                                 ReplyMsg((struct Message *)mess1);
  1061.  
  1062.                                 mess1=(struct IntuiMessage *) userport->mp_MsgList.lh_Head;
  1063.                                 }
  1064. d504 2
  1065. a505 2
  1066.                             break;
  1067.                         }
  1068. d507 2
  1069. a508 3
  1070.                     if(device && Queued[device])
  1071.                         qenter_tie(device,data);
  1072.                     }
  1073. a510 13
  1074.         } while(waitid>=0 && !waited);
  1075.  
  1076.     if(border_touch && waitid<0)
  1077.         {
  1078.         if(border_touch<0)
  1079.             {
  1080.             border_touch= -border_touch;
  1081.             data=TRUE;
  1082.             }
  1083.         else
  1084.             data=FALSE;
  1085.  
  1086.         border_action(border_touch,Mousex,Mousey,data);
  1087. a516 1
  1088.  
  1089. d570 1
  1090. a570 3
  1091. short     is_inside(long wid,short x,short y,short border)
  1092.  
  1093.     if border==TRUE, will also report inside if on border
  1094. d574 1
  1095. a574 1
  1096. short is_inside(long wid,short x,short y,short border)
  1097. d579 2
  1098. a580 8
  1099.     get_dimensions(wid,border,&posx,&posy,&lenx,&leny);
  1100.  
  1101.     x-=posx;
  1102.     y-=posy;
  1103.  
  1104.     inside=    x>=0 && x<lenx && y>=0 && y<leny;
  1105.  
  1106. /*     printf("border=%d pos=%d,%d len=%d,%d %d,%d inside=%d\n",border,posx,posy,lenx,leny,x,y,inside); */
  1107. a582 299
  1108.     }
  1109.  
  1110.  
  1111. /******************************************************************************
  1112. short    border_edge(long wid,short x,short y)
  1113.  
  1114.     returns which edge/corner is touched as sum of the following
  1115.         BORDER_LEFT
  1116.         BORDER_RIGHT
  1117.         BORDER_TOP
  1118.         BORDER_BOTTOM
  1119.         BORDER_MENU
  1120.  
  1121.     note that all combinations of flags are not possible
  1122.  
  1123.     assuming you know x,y is on the border, return of 0 indicates title bar
  1124. ******************************************************************************/
  1125. /*PROTOTYPE*/
  1126. short border_edge(long wid,short x,short y)
  1127.     {
  1128.     long posx,posy,lenx,leny;
  1129.  
  1130.     short result=0;
  1131.  
  1132.     get_dimensions(wid,TRUE,&posx,&posy,&lenx,&leny);
  1133.  
  1134.     x-=posx;
  1135.     y-=posy;
  1136.  
  1137.     if(x< BorderWidth+BorderHeight)
  1138.         result+=BORDER_LEFT;
  1139.  
  1140.     if(x> lenx - (BorderWidth+BorderHeight) )
  1141.         result+=BORDER_RIGHT;
  1142.  
  1143.     if(y< BorderWidth+BorderHeight)
  1144.         result+=BORDER_BOTTOM;
  1145.  
  1146.     if(y>= leny - (BorderWidth+BorderHeight) )
  1147.         result+=BORDER_TOP;
  1148.  
  1149.     if( x>= BorderWidth && x< lenx-BorderWidth && y>= BorderWidth && y< leny-BorderWidth )
  1150.         {
  1151.         if( x< BorderWidth+BorderHeight && y> leny-BorderWidth-BorderHeight )
  1152.             result=BORDER_MENU;
  1153.         else
  1154.             result=0;
  1155.         }
  1156.  
  1157.     return result;
  1158.     }
  1159.  
  1160.  
  1161. /******************************************************************************
  1162. void     border_action(long wid,short ox,short oy,short middle)
  1163.  
  1164. ******************************************************************************/
  1165. /*PROTOTYPE*/
  1166. void border_action(long wid,short ox,short oy,short middle)
  1167.     {
  1168.     long dx,dy;
  1169.     long x,y;
  1170.     long movex,movey;
  1171.     long sizex,sizey;
  1172.     long edge=0;
  1173.     long posx,posy,lenx,leny;
  1174.  
  1175.     short first=TRUE;
  1176.     short movefirst;
  1177.  
  1178.     get_dimensions(wid,TRUE,&posx,&posy,&lenx,&leny);
  1179.     posy=ScreenDef.Height-posy-leny;
  1180.  
  1181.     if(!middle && Sizeable[wid])
  1182.         edge=border_edge(wid,ox,oy);
  1183.  
  1184.     if(edge==BORDER_MENU)
  1185.         qenter(WINQUIT,TRUE);
  1186.     else
  1187.         {
  1188.         while( (!middle && getbutton(LEFTMOUSE)) || (middle && getbutton(MIDDLEMOUSE)) )
  1189.             {
  1190.             x=getvaluator(MOUSEX);
  1191.             y=getvaluator(MOUSEY);
  1192.  
  1193.             dx=x-ox;
  1194.             dy=y-oy;
  1195.  
  1196.             if(dx || dy)
  1197.                 {
  1198.                 if(first)
  1199.                     {
  1200.                     first=FALSE;
  1201.  
  1202.                     GLScreen->RastPort.BitMap=VisibleRPort->BitMap;
  1203.                     GLScreen->ViewPort.RasInfo->BitMap=VisibleRPort->BitMap;
  1204.  
  1205.                     MakeScreen(GLScreen);
  1206.                     RethinkDisplay();
  1207.                     }
  1208.  
  1209.                 sizex=0;
  1210.                 sizey=0;
  1211.  
  1212.                 movefirst=TRUE;
  1213.  
  1214.                 if(edge==0)
  1215.                     {
  1216.                     movex=dx;
  1217.                     movey= -dy;
  1218.                     }
  1219.                 else
  1220.                     {
  1221.                     movex=0;
  1222.                     movey=0;
  1223.                     }
  1224.  
  1225.                 if(edge&BORDER_TOP)
  1226.                     {
  1227.                     movey= -dy;
  1228.                     sizey=dy;
  1229.  
  1230.                     movefirst= (movey<0);
  1231.                     }
  1232.  
  1233.                 if(edge&BORDER_BOTTOM)
  1234.                     sizey= -dy;
  1235.  
  1236.                 if(edge&BORDER_LEFT)
  1237.                     {
  1238.                     movex=dx;
  1239.                     sizex= -dx;
  1240.  
  1241.                     movefirst= (movex<0);
  1242.                     }
  1243.  
  1244.                 if(edge&BORDER_RIGHT)
  1245.                     sizex=dx;
  1246.  
  1247.                 if(movex< -posx)
  1248.                     {
  1249.                     movex= -posx;
  1250.                     if(sizex)
  1251.                         sizex= -movex;
  1252.                     }
  1253.  
  1254.                 if(movey< -posy)
  1255.                     {
  1256.                     movey= -posy;
  1257.                     if(sizey)
  1258.                         sizey= -movey;
  1259.                     }
  1260.  
  1261.                 move_and_resize(wid,movefirst,movex,movey,sizex,sizey);
  1262.  
  1263.                 posx+=movex;
  1264.                 posy+=movey;
  1265.  
  1266.                 lenx+=sizex;
  1267.                 leny+=sizey;
  1268.                 }
  1269.  
  1270.             ox=x;
  1271.             oy=y;
  1272.             }
  1273.  
  1274.         clone_new_bitmap();
  1275.         }
  1276.     }
  1277.  
  1278.  
  1279. /******************************************************************************
  1280. void    do_move_and_resize(long wid,long movefirst,long movex,long movey,
  1281.                                                         long sizex,long sizey)
  1282.  
  1283.     does proper setup for double buffering
  1284.     calls move_and_resize()
  1285.  
  1286. ******************************************************************************/
  1287. /*PROTOTYPE*/
  1288. void do_move_and_resize(long wid,long movefirst,long movex,long movey,long sizex,long sizey)
  1289.     {
  1290. /*     printf("do(%d,%d, %d,%d, %d,%d)\n",wid,movefirst,movex,movey,sizex,sizey); */
  1291.  
  1292.     GLScreen->RastPort.BitMap=VisibleRPort->BitMap;
  1293.     GLScreen->ViewPort.RasInfo->BitMap=VisibleRPort->BitMap;
  1294.  
  1295.     MakeScreen(GLScreen);
  1296.     RethinkDisplay();
  1297.  
  1298.     move_and_resize(wid,movefirst,movex,movey,sizex,sizey);
  1299.  
  1300.     clone_new_bitmap();
  1301.     }
  1302.  
  1303.  
  1304. /******************************************************************************
  1305. void    move_and_resize(long wid,long movefirst,long movex,long movey,
  1306.                                                         long sizex,long sizey)
  1307.  
  1308. ******************************************************************************/
  1309. /*PROTOTYPE*/
  1310. void move_and_resize(long wid,long movefirst,long movex,long movey,long sizex,long sizey)
  1311.     {
  1312.     long posx,posy,lenx,leny;
  1313.     long limit;
  1314.  
  1315.     get_dimensions(wid,TRUE,&posx,&posy,&lenx,&leny);
  1316.     posy=ScreenDef.Height-posy-leny;
  1317.  
  1318. /*
  1319.     printf("\n wid=%d movefirst=%d pos=%d,%d+%d,%d size=%d,%d+%d,%d\n",wid,movefirst,posx,posy,movex,movey,
  1320.                                                                                 lenx,leny,sizex,sizey);
  1321. */
  1322.  
  1323.     if(lenx+sizex<MIN_WINX)
  1324.         sizex=MIN_WINX-lenx;
  1325.  
  1326.     if(leny+sizey<MIN_WINY)
  1327.         sizey=MIN_WINY-leny;
  1328.  
  1329.     limit=ScreenDef.Width-posx-lenx-sizex;
  1330.     if(movex>limit && limit>=0)
  1331.         movex=limit;
  1332.  
  1333.     limit=ScreenDef.Height-posy-leny-sizey;
  1334.     if(movey>limit && limit>=0)
  1335.         movey=limit;
  1336.  
  1337.     if(movex< -posx)
  1338.         movex= -posx;
  1339.  
  1340.     if(movey< -posy)
  1341.         movey= -posy;
  1342.  
  1343.     limit=ScreenDef.Width-posx-lenx-movex;
  1344.     if(sizex>limit && limit>=0)
  1345.         sizex=limit;
  1346.  
  1347.     limit=ScreenDef.Height-posy-leny-movey;
  1348.     if(sizey>limit && limit>=0)
  1349.         sizey=limit;
  1350.  
  1351. /*
  1352.     printf("                   pos=%d,%d+%d,%d size=%d,%d+%d,%d\n",posx,posy,movex,movey,
  1353.                                                                                 lenx,leny,sizex,sizey);
  1354. */
  1355.  
  1356.     if( movefirst && (movex || movey) )
  1357.         {
  1358.         MoveWindow(GLWindow[wid],movex,movey);
  1359.         update_queue(wid);
  1360.         }
  1361.  
  1362.     if(sizex || sizey)
  1363.         {
  1364.         SizeWindow(GLWindow[wid],sizex,sizey);
  1365.         update_queue(wid);
  1366.  
  1367.         clear_void(wid,sizex,sizey);
  1368.         }
  1369.  
  1370.     if( !movefirst && (movex || movey) )
  1371.         {
  1372.         MoveWindow(GLWindow[wid],movex,movey);
  1373.         update_queue(wid);
  1374.         }
  1375.  
  1376.     drawborder(wid);
  1377.     }
  1378.  
  1379.  
  1380. /******************************************************************************
  1381. void    clear_void(long wid,short x,short y)
  1382.  
  1383.     clears space left by expanding window
  1384. ******************************************************************************/
  1385. /*PROTOTYPE*/
  1386. void clear_void(long wid,short x,short y)
  1387.     {
  1388.     struct RastPort *rp;
  1389.  
  1390.     long posx,posy,lenx,leny;
  1391.  
  1392.     rp=GLWindow[wid]->RPort;
  1393.  
  1394.     get_dimensions(wid,TRUE,&posx,&posy,&lenx,&leny);
  1395.  
  1396.     SetAPen(rp,0);
  1397.  
  1398.     deactivate_clipping(wid);
  1399.  
  1400.     if(x>0)
  1401.         RectFill(rp,lenx-BorderWidth-x,BorderWidth+BorderHeight,lenx-BorderWidth,leny-BorderWidth);
  1402.  
  1403.     if(y>0)
  1404.         RectFill(rp,BorderWidth,leny-BorderWidth-y,lenx-BorderWidth,leny-BorderWidth);
  1405.  
  1406.     activate_clipping(wid);
  1407. @
  1408.  
  1409.  
  1410. 1.2.1.5
  1411. log
  1412. @border buttons with feedback
  1413. @
  1414. text
  1415. @d1 1
  1416. d4 1
  1417. a4 4
  1418. Copyright © 1994 Jason Weber
  1419. All Rights Reserved
  1420.  
  1421. $Id: que.c,v 1.2.1.4 1994/11/16 06:28:44 jason Exp jason $
  1422. a6 3
  1423.  * Revision 1.2.1.4  1994/11/16  06:28:44  jason
  1424.  * border support
  1425.  *
  1426. a29 1
  1427. #define BORDER_TITLE    0
  1428. a34 2
  1429. #define BORDER_MINIMIZE    32
  1430. #define BORDER_MAXIMIZE    64
  1431. d381 1
  1432. a381 1
  1433.                 originy=ScreenHeight-originy-sizey;
  1434. d423 1
  1435. a423 1
  1436.                                                     class!=ACTIVEWINDOW && class!=INACTIVEWINDOW )
  1437. d432 1
  1438. a432 1
  1439.                                                 ButtonState[MIDDLEMOUSE],ButtonState[RIGHTMOUSE],code);
  1440. d469 1
  1441. a469 1
  1442.                             drawborder(wid,0);
  1443. d484 2
  1444. a485 2
  1445.                             drawborder(old_wid,0);
  1446.                             drawborder(wid,0);
  1447. d503 1
  1448. a503 1
  1449.                                 drawborder(old_wid,0);
  1450. d589 1
  1451. a589 2
  1452.                                                 printf("     %2x %3d '%c'\n",
  1453.                                                                         string[c],string[c],string[c]);
  1454. a738 2
  1455.         BORDER_MINIMIZE
  1456.         BORDER_MAXIMIZE
  1457. d770 3
  1458. a772 3
  1459.         /* not on outer edge */
  1460.  
  1461.         if( y <= leny-BorderWidth-BorderHeight )
  1462. a773 13
  1463.         else
  1464.             {
  1465.             /* title bar */
  1466.  
  1467.             if( x< BorderWidth+BorderHeight )
  1468.                 result=BORDER_MENU;
  1469.             else if( x>= lenx-BorderWidth-BorderHeight )
  1470.                 result=BORDER_MAXIMIZE;
  1471.             else if( x>= lenx-BorderWidth-2*BorderHeight )
  1472.                 result=BORDER_MINIMIZE;
  1473.             else
  1474.                 result=0;
  1475.             }
  1476. a786 1
  1477.     long old_wid;
  1478. d791 1
  1479. a792 1
  1480.     long edge=BORDER_TITLE;
  1481. d798 1
  1482. a798 3
  1483.     posy=ScreenHeight-posy-leny;
  1484.  
  1485.     edge=border_edge(wid,ox,oy);
  1486. d800 2
  1487. a801 2
  1488.     if( (middle || !Sizeable[wid]) && edge!=BORDER_MENU)
  1489.         edge=BORDER_TITLE;
  1490. a803 8
  1491.         {
  1492.         drawborder(wid,1);
  1493.  
  1494.         while( (!middle && getbutton(LEFTMOUSE)) || (middle && getbutton(MIDDLEMOUSE)) )
  1495.             /* NOP */ ;
  1496.  
  1497.         drawborder(wid,0);
  1498.  
  1499. a804 40
  1500.         }
  1501.     else if(edge==BORDER_MINIMIZE)
  1502.         {
  1503.         drawborder(wid,3);
  1504.  
  1505.         while( (!middle && getbutton(LEFTMOUSE)) || (middle && getbutton(MIDDLEMOUSE)) )
  1506.             /* NOP */ ;
  1507.  
  1508.         drawborder(wid,0);
  1509.         }
  1510.     else if(edge==BORDER_MAXIMIZE)
  1511.         {
  1512.         drawborder(wid,4);
  1513.  
  1514.         while( (!middle && getbutton(LEFTMOUSE)) || (middle && getbutton(MIDDLEMOUSE)) )
  1515.             /* NOP */ ;
  1516.  
  1517.         get_dimensions(wid,FALSE,&posx,&posy,&lenx,&leny);
  1518.  
  1519.         x=Maximization[wid][0];
  1520.         y=Maximization[wid][1];
  1521.         dx=x+Maximization[wid][2]-1;
  1522.         dy=y+Maximization[wid][3]-1;
  1523.  
  1524. /*
  1525.         printf("\n%d,%d %d,%d,%d,%d %d,%d\n",ScreenWidth,ScreenHeight,
  1526.                                                                 BorderWidth,BorderHeight,x,y,dx,dy);
  1527. */
  1528.         old_wid=winget();
  1529.         winset(wid);
  1530.  
  1531.         winposition(x,dx,y,dy);
  1532.  
  1533.         Maximization[wid][0]=posx;
  1534.         Maximization[wid][1]=posy;
  1535.         Maximization[wid][2]=lenx;
  1536.         Maximization[wid][3]=leny;
  1537.  
  1538.         winset(old_wid);
  1539.         }
  1540. a806 3
  1541.         if(!middle && edge==0)
  1542.             drawborder(wid,2);
  1543.  
  1544. a881 3
  1545.                 if(!middle && edge==0)
  1546.                     drawborder(wid,2);
  1547.  
  1548. a892 2
  1549.         drawborder(wid,0);
  1550.  
  1551. d935 1
  1552. a935 1
  1553.     posy=ScreenHeight-posy-leny;
  1554. d938 2
  1555. a939 2
  1556.     printf("\n wid=%d movefirst=%d pos=%d,%d+%d,%d size=%d,%d+%d,%d\n",wid,movefirst,posx,posy,
  1557.                                                                 movex,movey,lenx,leny,sizex,sizey);
  1558. d948 1
  1559. a948 1
  1560.     limit=ScreenWidth-posx-lenx-sizex;
  1561. d952 1
  1562. a952 1
  1563.     limit=ScreenHeight-posy-leny-sizey;
  1564. d962 1
  1565. a962 1
  1566.     limit=ScreenWidth-posx-lenx-movex;
  1567. d966 1
  1568. a966 1
  1569.     limit=ScreenHeight-posy-leny-movey;
  1570. d972 1
  1571. a972 1
  1572.                                                                             lenx,leny,sizex,sizey);
  1573. d994 2
  1574. @
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.